<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:a="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich"
    template="/layout/template.xhtml">

<ui:define name="body">

    <h:form id="telefone" styleClass="edit">

        <rich:panel>
            <f:facet name="header">#{telefoneHome.managed ? 'Editar' : 'Cadastro de'} Telefone</f:facet>

            <s:decorate id="contatoField" template="/layout/edit.xhtml">
                <ui:define name="label">Contato</ui:define>
                <h:inputText id="contato" value="#{telefoneHome.instance.contato}" required="true"/>
            </s:decorate>


            <s:decorate id="numeroField" template="/layout/edit.xhtml">
                <ui:define name="label">Número</ui:define>
                <h:inputText id="numero" value="#{telefoneHome.instance.numero}" required="true"/>
            </s:decorate>


            <s:decorate id="ramalField" template="/layout/edit.xhtml">
                <ui:define name="label">Ramal</ui:define>
                <h:inputText id="ramal" value="#{telefoneHome.instance.ramal}"/>
            </s:decorate>


            <s:decorate id="tipoTelefoneField" template="/layout/edit.xhtml">
                <ui:define name="label">Tipo de Telefone</ui:define>
                <h:selectOneRadio id="tipoTelefone" value="#{telefoneHome.instance.tipoTelefone}" styleClass="radio" required="true">
                    <f:selectItem itemLabel="Celular" itemValue="Celular"/>
                    <f:selectItem itemLabel="Comercial" itemValue="Comercial"/>
                    <f:selectItem itemLabel="Residencial" itemValue="Residencial"/>
                    <f:selectItem itemLabel="Outro" itemValue="Outro"/>
                </h:selectOneRadio>
            </s:decorate>

            <div style="clear:both">
                <span class="required">*</span>
                campos obrigatórios
            </div>

        </rich:panel>

        <div class="actionButtons">

            <h:commandButton id="save"
                          value="Salvar"
                         action="#{telefoneHome.persist}"
                       disabled="#{!telefoneHome.wired}"
                       rendered="#{!telefoneHome.managed}"/>

            <h:commandButton id="update"
                          value="Salvar"
                         action="#{telefoneHome.update}"
                       rendered="#{telefoneHome.managed}"/>

            <h:commandButton id="delete"
                          value="Deletar"
                         action="#{telefoneHome.remove}"
                      immediate="true"
                       rendered="#{telefoneHome.managed}"/>

            <s:button id="cancelEdit"
                   value="Cancelar"
             propagation="end"
                    view="/resources/Telefone.xhtml"
                rendered="#{telefoneHome.managed}"/>

            <s:button id="cancelAdd"
                   value="Cancelar"
             propagation="end"
                    view="/resources/#{empty telefoneFrom ? 'TelefoneList' : telefoneFrom}.xhtml"
                rendered="#{!telefoneHome.managed}"/>

        </div>
    </h:form>

<rich:tabPanel switchType="ajax">

    <rich:tab label="Administrador grupo">
    <div class="association" id="administradorGrupoParent">

        <h:outputText value="Não existe Administrador de Grupo associado."
                   rendered="#{telefoneHome.instance.administradorGrupo == null}"/>

        <rich:dataTable var="_administradorGrupo"
                   value="#{telefoneHome.instance.administradorGrupo}"
                rendered="#{telefoneHome.instance.administradorGrupo != null}"
              rowClasses="odd,even"
                      id="administradorGrupoTable">
            <h:column>
                <f:facet name="header">Nome</f:facet>
                <h:outputText value="#{_administradorGrupo.nome}"/>
            </h:column>
            <h:column>
                <f:facet name="header">E-mail</f:facet>
                <h:outputText value="#{_administradorGrupo.email}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Status</f:facet>
                <h:outputText value="#{_administradorGrupo.status}"/>
            </h:column>
        </rich:dataTable>

        <div class="actionButtons">
            <s:button id="#{telefoneHome.instance.administradorGrupo != null ? 'changeParent' : 'selectParent'}" value="#{telefoneHome.instance.administradorGrupo != null ? 'Alterar o' : 'Selecionar'} Administrador de Grupo"
                       view="/resources/AdministradorGrupoList.xhtml">
                <f:param name="from" value="TelefoneEdit"/>
            </s:button>
        </div>

    </div>
    </rich:tab>
</rich:tabPanel>
</ui:define>

</ui:composition>
